// var PearPlayer = require('PearPlayer');
// // 检测 WebRTC
// var cheackRTC = function() {
//   var html = `cheackRTC-no`
//   var cheackRTCclick = document.querySelector('#source-header-setcolor')
//   cheackRTCclick.insertAdjacentHTML("beforeend", html)
//   }
//
// function onBegin(fileLength) {
//     console.log('start downloading buffer by first aid, file length is:' + fileLength);
// }
//
// function onProgress(downloaded) {
//     console.log('Progress: ' + (downloaded * 100).toFixed(1) + '%');
// }
//
// function onHttpSpeed(httpSpeed) {
//     console.log('http download speed: ' + httpSpeed + 'Kbps');
// }
//
// function onP2PSpeed(p2pSpeed) {
//     console.log('p2p download speed: ' + p2pSpeed + 'Kbps');
// }
//
// function onP2PRate(p2pRate) {
//     console.log('P2P Rate: ' + (p2pRate * 100).toFixed(1) + '%');
// }
//
// function onDone() {
//     console.log('finished downloading buffer by first aid');
// }
//
// function onException(errCode) {
//     switch (errCode) {
//         case 1:
//             console.log('Your browser do not support WebRTC communication!');
//             break
//     }
// }


// 默认 cloud 显示加载速度
var defaultDownSpeed = 0

// 默认 Fog下载速度
var defaultFogDownSpeed = 0

// 默认的 Fog 下载数据
var defaultFogRate = 0

// 下载数据大小
var defaulfFileLength = 0
var defaultDownloaded = 0
var defaultP2pRate = 0

// 默认的数字下载小方格
var defaultDownButton = 0

//  视频下载类型的启动值
var defaultVideoStartValue = []

var smoothie = new SmoothieChart({
  grid: { strokeStyle:'rgb(0, 0, 0)', fillStyle:'rgb(0, 0, 0)',},
  labels: { fillStyle:'rgb(0, 0, 0)', disabled:true,},
  // timestampFormatter:SmoothieChart.timeFormatter,
});
smoothie.streamTo(document.getElementById("mycanvas"), 1000);
// Data
var line1 = new TimeSeries();
var line2 = new TimeSeries();
// Add to SmoothieChart
smoothie.addTimeSeries(line1,
  { strokeStyle:'rgb(0, 255, 0)', fillStyle:'rgba(255, 255, 255, 0)', lineWidth:3 });
smoothie.addTimeSeries(line2,
  { strokeStyle:'rgb(255, 0, 0)', fillStyle:'rgba(255, 255, 255, 0)', lineWidth:3 });

var setHttpSpeed = function(number) {
  var httpSpeedBtn = document.querySelector(".http-speed-number")
  httpSpeedBtn.innerText = ''
  // console.log('p2p-speed-show', httpSpeedBtn)
  // var number = Math.floor(Math.random() *10)
  var html = `<span>  ${number} Kbps</span>`
  httpSpeedBtn.insertAdjacentHTML("beforeend", html)
}


//network
var network_nodes = new vis.DataSet([
    {id: 1, label: 'You', shape: 'ellipse'},
]);

// create an array with edges
var network_edges = new vis.DataSet();

// create a network
var container = document.getElementById('mynetwork');

// provide the data in the vis format
var data = {
    nodes: network_nodes,
    edges: network_edges
};
var options = {
    nodes: {shape: 'dot'},
};

// initialize your network!
var network = new vis.Network(container, data, options);

//获取文件长度，以及chunk值
function onBegin(fileLength, numbers) {
    console.log('start downloading buffer by first aid, file length is:' + fileLength);
    defaulfFileLength = fileLength
    defaultDownButton = numbers

    //监控
    var debugInfo = window.player.debugInfo;
    /*
     totalDCs: 0,
     connectedDCs: 0,
     usefulDCs: 0,
     totalHTTP: 0,
     totalHTTPS: 0,
     usefulHTTPAndHTTPS: 0,
     windowOffset: 0,
     windowLength: 0,
     signalServerConnected: false
     */
    setInterval(function () {

        var el_http = document.getElementById("monitor-http");
        el_http.innerText = '获取http节点：'+debugInfo.totalHTTP+'，获取https节点：'+debugInfo.totalHTTPS+'，可用：'+
            debugInfo.usefulHTTPAndHTTPS;

        var el_dc = document.getElementById("monitor-datachannel");
        el_dc.innerText = 'data channel总数：'+debugInfo.totalDCs+'，可以建立连接数：'+debugInfo.connectedDCs+'，no such file数：'+
            (debugInfo.connectedDCs-debugInfo.usefulDCs);

        var el_window = document.getElementById("monitor-window");
        el_window.innerText = '当前窗口偏移：'+debugInfo.windowOffset+'，窗口长度：'+debugInfo.windowLength;

        var el_signaler = document.getElementById("monitor-signaler");
        el_signaler.innerText = '信令服务器已连接：'+(debugInfo.signalServerConnected ? 'Yes' : 'No');



    }, 5000);
}
//下载进度（百分比）
function onProgress(downloaded) {
    console.log('Progress: ' + (downloaded * 100).toFixed(1) + '%');
    defaultDownloaded = downloaded

    var el_pro = document.getElementById("monitor-progress");
    el_pro.innerText = '下载进度：'+(downloaded * 100).toFixed(1) + '%';
}
//Cloud下载速率KBps
function onCloudSpeed(httpSpeed) {
  console.log('Cloud download speed: ' + httpSpeed + 'KBps');
  defaultDownSpeed = httpSpeed
}
//fog下载速率KBps
function onFogSpeed(speed) {
  console.log('Fog download speed: ' + speed + 'KBps');
  defaultFogDownSpeed = speed
}
//WebRTC下载速率KBps
function onWebRTCRate(p2pRate) {
  console.log('Fog Rate: ' + (p2pRate * 100).toFixed(1) + '%');
  defaultFogRate = Math.floor(p2pRate * 100) > 100 ? 100 : Math.floor(p2pRate * 100);
  findFogSetNumber(defaultFogRate)
  defaultP2pRate = p2pRate
  setTimeout(function() {
    showInfoForButton()
  }, 30)
}
//下载结束
function onDone() {
  console.log('finished downloading buffer by first aid');
}
//错误日志
function onException(exception) {
  var errCode = exception.errCode;
  switch (errCode) {
    case 1:
        console.log(exception.errMsg);
        supportWebRTCBrower()
        break
  }
}


//视频长度以方格个数形式展示
function onBufferSources(bufferSources) {            //s: server   n: node  d: data channel  b: browser
  console.log('Current Buffer Sources:' + bufferSources);
  // console.log("bufferSources.length", bufferSources.length)
  defaultDownButton = bufferSources.length
  defaultVideoStartValue = bufferSources
  console.log('Current Buffer Sources:' + defaultVideoStartValue);
  console.log('Current Buffer Sources:' + defaultDownButton);

}

var macMap = {};

function onTraffic(mac, downloaded, type) {
// console.log('type:'+type+' mac:'+mac+' downloaded:'+downloaded/1024/1024+'MB');
if (macMap[mac]) {
  // $(".downloadBlock tbody").find(".trafficMac").each(function(){
  //     $(this).innerText=;
  //     var mac = tdArr[1].text;//收入类别
  //     // console.log('traffic-mac:'+mac);
  //
  // });
  $(".downloadBlock tbody tr").each(function () {
      var tdArr = $(this).children();
      // console.log('traffic-mac:'+tdArr.eq(1).text());
      if (tdArr.eq(1).text() === mac) {
          macMap[mac] += downloaded;
          tdArr.eq(2).html(Math.floor(macMap[mac]/1024/1024) + 'MB');
      }
  });
} else {
  macMap[mac] = downloaded;
  var child = `<tr>
    <td>${type}</td>
    <td class="trafficMac">${mac}</td>
    <td>${Math.floor(macMap[mac]/1024/1024)} MB</td>
    </tr>`;
  $('.downloadBlock tbody').append(child);

    //network
    var color = 'blue';
    var id = mac.substring(mac.length-2);
    switch (type) {
        case 'HTTP_Node':
            color = 'blue'
            break
        case 'HTTP_Server':
            color = 'red'
            break
        case 'WebRTC_Node':
            color = 'green'
            break
        case 'WebRTC_Browser':
            color = 'purple'
            break
        default:
    }
    network_nodes.add({
        id: mac,
        label: id,
        color: color
    });

    network_edges.add({
        from: 1,
        to: mac,
        arrows: 'from',
        length: Math.floor(Math.random() * (150 - 20 + 1)) + 20
    });
}


}


// colud下载速度 setHttpSpeed(httpSpeed)
setInterval(function() {
// console.log("3!!!!!!!!!!!!!!!!!!!!!!!")
  if ( defaultDownSpeed > 0) {
    defaultDownSpeed = defaultDownSpeed * 8
    setHttpSpeed(defaultDownSpeed)
    line2.append(new Date().getTime(), defaultDownSpeed)
    defaultDownSpeed = 0
    } else {
    setHttpSpeed(0)
    line2.append(new Date().getTime(), 0)
  }
}, 2000)

// Fog 下载速度
setInterval(function() {
// console.log('Fog downspeed------')
// console.log("2!!!!!!!!!!!!!!!!!!!!")
  if (defaultFogDownSpeed > 0) {
    defaultFogDownSpeed = defaultFogDownSpeed * 8
    fogSpeed(defaultFogDownSpeed)
    line1.append(new Date().getTime(), defaultFogDownSpeed)
    defaultFogDownSpeed = 0
    } else {
    fogSpeed(0)
    line1.append(new Date().getTime(), 0)
  }
}, 1000)

// 加载数据百分比位置
var findFogSetNumber = function(number) {
  var findFogButton = document.querySelector(".speed-item-show-precent")
  findFogButton.innerText = ''
  var html = `<span>  ${number} %</span>`
  findFogButton.insertAdjacentHTML("beforeend", html)
}

// Fog 加载文件大小
var FogDownFileSize = function() {
  var findFogFileSizeButton = document.querySelector('.speed-item-show-unit')
  findFogFileSizeButton.innerText = ''
  var number = Math.ceil((defaulfFileLength *　defaultDownloaded * defaultP2pRate) / 1048576);
  var filesize = Math.ceil(defaulfFileLength / 1048576);
  var html = `<span>(  ${number} M / ${filesize} M)</span>`
  findFogFileSizeButton.insertAdjacentHTML("beforeend", html)
}

//每秒重新加载文件大小
setInterval(function() {
  FogDownFileSize()
// console.log("@!!!!!!!!!!!!!!!!!!!!!!")
}, 1000)

// 获得设置获取数据
// console.log('peardata.js')
var setPlayerNode = document.querySelector("#setParent")
var setPlayerNumber = document.querySelector("#setChild")
var setBlooeanNode = document.querySelector("#parent")
var setBlooeanValue = document.querySelector("#child")
var setNewSource = document.querySelector("#set-newsource")
var setPlayerButton = document.querySelector(".set-player-start-button")
var setFirstaidSetarrButton = document.querySelector("#Firstaid-setParent")


// 合并 object 用于手动设置项与默认设置项合并
var pushFunction = function(value1, value2) {
  var ObjAll = Object.assign(value1, value2)
  console.log('yes', ObjAll)
  return ObjAll
}

// 可设置项
// var selectSetOptions = {
//         src: 'https://qq.webrtc.win/tv/pear001.mp4',  //视频播放的src
//         chunkSize: 512*1024,        //每个chunk的大小,必须是32K的整数倍,默认1M
//         urgent: 2,                  //urgent的块数,默认2
//         normal: 3,                  //normal的块数,默认3
//         prefetch: 2,                //prefetch(用data channel下载)的块数,默认3
//         interval: 5000,             //滑动窗口的时间间隔,单位毫秒,默认10s
//         auto: true,                //true为连续下载buffer,false则是只有当前播放时间与已缓冲时间小于slideInterval时下载buffer,如果是fmp4建议设为true,默认false
//         timeout: 5000,              //连接data channel的超时时间,单位毫秒,默认5s
//         reconnectTimes: 0,          //超时重连次数,默认0次(未实现)
//         slideInterval: 10,          //当前播放时间与已缓冲时间小于这个数值时触发窗口滑动,单位秒,默认20s
//         useDataChannel: false,       //是否开启data channel,默认true
// }
var selectSetOptions = {
  src: 'https://qq.webrtc.win/tv/pear001.mp4',  //视频播放的src
  chunkSize: 1*1024*1024,        //每个chunk的大小,必须是32K的整数倍,默认1M
  params: {                   //核心算法的参数
    urgent: 1,                  //urgent的块数,默认2
    normal: 2,                  //normal的块数,默认3
    prefetch: 3                //prefetch(用data channel下载)的块数,默认3
  },
  interval: 5000,             //滑动窗口的时间间隔,单位毫秒,默认10s
  auto: false,                //true为连续下载buffer,false则是只有当前播放时间与已缓冲时间小于slideInterval时下载buffer,如果是fmp4建议设为true,默认false
  timeout: 5000,              //连接data channel的超时时间,单位毫秒,默认5s
  reconnectTimes: 0,          //超时重连次数,默认0次(未实现)
  slideInterval: 20,          //当前播放时间与已缓冲时间小于这个数值时触发窗口滑动,单位秒,默认20s
  useDataChannel: true,       //是否开启data channel,默认true
}
// 设置播放数据
var setDownData = function() {
// 第一个选择框的值
var selectorset = setPlayerNode.value
if (!selectorset == 0) {
  var selectorsetN = setPlayerNode.options[selectorset].text
  // 第一个填空的值
  var inputN = setPlayerNumber.value
  console.log('selectorset', selectorsetN)
  console.log('inputN', inputN)
  selectSetOptions[selectorsetN] = inputN
}
// 第二选择的第一个选择框的值
var setP = setBlooeanNode.value
  if (!setP == 0) {
    var setPN = setBlooeanNode.options[setP].text
    // 第二选择的第二个选择框的值
    var setC = setBlooeanValue.value
    var setCN = setBlooeanValue.options[setC].text
    console.log('setP', setPN)
    console.log('setC', setCN)
    selectSetOptions[setPN] = parseInt(setCN)
    console.log('show----')
    console.log('typeof selectSetOptions', typeof(selectSetOptions[setPN]))
  }
}
// 设置播放路径
var setManulPlayer = function() {
  var setSrcNewSource = setNewSource.value
  console.log("setSrcNewSource", setSrcNewSource)
  if(setSrcNewSource.length > 1) {
    selectSetOptions["src"] = setSrcNewSource
  } else{
    console.log('你输入的网址不正确')
  }
}
// 点击播放设置数据生效
var setPlayerStart = function() {
  setPlayerButton.addEventListener('click', function() {
    setPlayFuncitonforplaybutton()
    // setDownData()
    // setFirstaidSetarr()
    setManulPlayer()
    myvideo.removeEventListener('play',fn,false);//移除重复play监听事件
  })
}
setPlayerStart()

// 判断设置数据
var judgeSetPlayer = function() {
  var judgesetPlayerNode = setPlayerNode.value
  var judgesetPlayerNumber = setPlayerNumber.value
  var judgesetBlooeanNode = setBlooeanNode.value
  var judgesetBlooeanValue = setBlooeanValue.value
  if (true) {

  }
}
// 点击播放按钮时的响应发送设置数据给服务器
var setPlayFuncitonforplaybutton = function() {
var Admin = 'admin'
var userPwd = '123456'
console.log('login')
var xhr = new XMLHttpRequest();
self._xhr = xhr;
xhr.open("POST", 'https://api.webrtc.win:6601/v1/customer/login');
var data = JSON.stringify({
  username: Admin ,
  password: userPwd ,
});
xhr.onload = function () {
if (this.status >= 200 && this.status < 300) {

    var res = JSON.parse(this.response);
    var defalutOptions = {
                                        //第一个参数为video标签的id或class
            type: 'mp4',                //播放视频的类型,目前只能是mp4
            token: res.token,           //与信令服务器连接的token,必须
            autoplay: true,            //是否自动播发视频,默认true
            controls: true,            //是否显示控制条,默认true
            useMonitor: true               //是否开启monitor,会稍微影响性能,默认true
    }
    // var Options = {      //第一个参数为video标签的id或class
    //       type: 'mp4',                //播放视频的类型,目前只能是mp4
    //       src: 'https://qq.webrtc.win/tv/pear001.mp4',  //视频播放的src
    //       token: res.token,           //与信令服务器连接的token,必须
    //       autoplay: true,            //是否自动播发视频,默认true
    //       controls: true,            //是否显示控制条,默认true
    //       chunkSize: 512*1024,        //每个chunk的大小,必须是32K的整数倍,默认1M
    //       urgent: 2,                  //urgent的块数,默认2
    //       normal: 3,                  //normal的块数,默认3
    //       prefetch: 2,                //prefetch(用data channel下载)的块数,默认3
    //       interval: 5000,             //滑动窗口的时间间隔,单位毫秒,默认10s
    //       auto: false,                //true为连续下载buffer,false则是只有当前播放时间与已缓冲时间小于slideInterval时下载buffer,如果是fmp4建议设为true,默认false
    //       timeout: 5000,              //连接data channel的超时时间,单位毫秒,默认5s
    //       reconnectTimes: 0,          //超时重连次数,默认0次(未实现)
    //       slideInterval: 10,          //当前播放时间与已缓冲时间小于这个数值时触发窗口滑动,单位秒,默认20s
    //       useDataChannel: false,       //是否开启data channel,默认true
    //       useMonitor: true               //是否开启monitor,会稍微影响性能,默认true
    //   }
    var Options = pushFunction(defalutOptions, selectSetOptions)
    console.log('Options', Options)
    if (!!res.token){
        // console.log('token:' +res.token);
        // var player = new PearPlayer('#pearvideo', Options, function (monitor) {
        //
        //     // monitor.on('exception', onException);
        //     // monitor.on('begin', onBegin);
        //     // monitor.on('progress', onProgress);
        //     // monitor.on('httpspeed', onHttpSpeed);
        //     // monitor.on('p2pspeed', onP2PSpeed);
        //     // monitor.on('p2prate', onP2PRate);
        //     // monitor.on('done', onDone);
        // });
       var player = new PearPlayer('#pearvideo', res.token, Options)
        window.player = player;
        player.on('exception', onException);
        player.on('begin', onBegin);
        player.on('progress', onProgress);
        player.on('cloudspeed', onCloudSpeed);
        player.on('fogspeed', onFogSpeed);
        player.on('fograte', onWebRTCRate);
        // player.on('buffersources', onBufferSources);
        player.on('sourcemap', onMap);
        player.on('done', onDone);
        player.on('traffic', onTraffic);
        player.on('metadata', onMetaData);
        // player.on('info', onPlayerInfo);
        // player.on('fillwindow', onFillWindow);
    }
  } else {
    alert('请求出错!');
  }
  };
  xhr.send(data);
}

//metadata
function onMetaData(metadata) {
    // console.log('metadata bitrate:'+metadata.bitrate/1024+' KB/s');
    var el_bitrate = document.getElementById("monitor-bitrate");
    el_bitrate.innerText = '视频平均码率：' + Math.round(metadata.bitrate/1024)+' KB/s';
}

//监控
// var _http = 0;
// var _https = 0;
// var _usefulHttp = 0;
// var _dc = 0;
// var _connectedDC = 0;
// var _usefulDC = 0;
// function onPlayerInfo(info) {
//     console.log('info http:'+info.http+'https:'+info.https+' usefulHttp:'+info.usefulHttp+' datachannels:'+info.datachannels+' connectedDC:'+info.connectedDC);
//     for (var prop in info) {
//        if (info[prop] !== undefined) {
//          switch (prop) {
//              case 'http':
//                  _http = info[prop];
//              case 'https':
//                  _https = info[prop];
//              case 'usefulHttp':
//                  _usefulHttp = info[prop];
//              case 'datachannels':
//                  _dc = info[prop];
//              case 'connectedDC':
//                  _connectedDC = info[prop];
//              case 'usefulDC':
//                  _usefulDC = info[prop];
//          }
//        }
//     }
//
//     var el_http = document.getElementById("monitor-http");
//     el_http.innerText = '获取http节点：'+_http+'，获取https节点：'+_https+'，可用：'+_usefulHttp;
//
//     var el_dc = document.getElementById("monitor-datachannel");
//     el_dc.innerText = '获取data channel总数：'+_dc+'，成功连接：'+_connectedDC+'，出错：'+(_connectedDC-_usefulDC);
//
//
// }
//
// function onFillWindow(windowOffset, windowLength) {
//
//     var el_window = document.getElementById("monitor-window");
//     el_window.innerText = '当前窗口偏移：'+windowOffset+'，窗口长度：'+windowLength;
// }

//节点来源
var flag = false;
function onMap(sourceType, index) {
  // console.log('sourceType :'+ sourceType +'/'+'index :'+index);
  if (!flag) {
    toggoleObser();
    flag = true;
  }

  showdata = sourceType;
  i = index
  var setDownColorClass = document.querySelectorAll(".insertButton")
  if (setDownColorClass.length > 0) {
    if (showdata == "s") {
      setDownColorClass[i].classList.add('serverColor')
    } else if (showdata == "n") {
      setDownColorClass[i].classList.add('nodeColor')
    }  else if (showdata == "undefined") {
      setDownColorClass[i].classList.add('defualtColor')
    } else if (showdata == "d") {
      setDownColorClass[i].classList.add('dataChannelColor')
    }else if (showdata == "b") {
      setDownColorClass[i].classList.add('browserColor')
    }
  }  
}



// 生成一连串的方格子用于呈现下载数据类型
var insertbutton = function(buttonNumbers) {
// var html = `<button type = 'button'class = "insertButton"></button>`
  var findeInsert = document.querySelector('.downDataProgress')
  for(var i = 0 ; i < buttonNumbers; i++) {
    var html = `<button type = 'button'class = "insertButton"></button>`
    findeInsert.insertAdjacentHTML("beforeend", html)
  }
}
// 点击进入或者退出观测界面
var toggoleObser = function() {
  var findToggle = document.querySelector('.obrDropdown')
  findToggle.classList.add('show-obser-button')
  insertbutton(defaultDownButton)
  toggoleDefault()
  findeVideoButton()
  // readyDownDataArr()
  clickProgressArea()
}
// 点击出现或消失默认的颜色值
var toggoleDefault = function() {
var findDefaultColor = document.querySelector(".setDownTypeArea")
// console.log("findeDefaultColor", findDefaultColor)
  if(findDefaultColor.classList.contains("setDownTypeAreaShow")) {
    findDefaultColor.classList.remove("setDownTypeAreaShow")
  } else {
    findDefaultColor.classList.add("setDownTypeAreaShow")
  }
}

// 定义一个取得 class 的函数
var e = function(selector) {
  return document.querySelectorAll(selector)
}
// 关联视频下载类型与下载显示方格
// var readyDownDataArr = function() {
//   for (var i = 0; i < defaultVideoStartValue.length; i++) {
//     var showdata = defaultVideoStartValue[i]
//     // console.log(i, showdata)
//     var setDownColorClass = document.querySelectorAll(".insertButton")
//     if (showdata == "s") {
//         if (setDownColorClass.length > 0) {
//             setDownColorClass[i].classList.add('serverColor')
//         }
//     } else if (showdata == "n") {
//       if (setDownColorClass.length > 0) {
//           setDownColorClass[i].classList.add('nodeColor')
//       }
//     }  else if (showdata == "undefined") {
//       if (setDownColorClass.length > 0) {
//         setDownColorClass[i].classList.add('defualtColor')
//         }
//       } else if (showdata == "d") {
//         if (setDownColorClass.length > 0) {
//           setDownColorClass[i].classList.add('dataChannelColor')
//       }
//     }else if (showdata == "b") {
//         if (setDownColorClass.length > 0) {
//             setDownColorClass[i].classList.add('browserColor')
//         }
//     }
//   }
// }


// 显示或关闭进度
var  clickProgressArea = function() {
  var clickArea = document.querySelector('.downDataProgress')
  if (clickArea.classList.contains('defaultdownDataProgress')) {
    clickArea.classList.remove('defaultdownDataProgress')
  }
}

// if (showdata == "s") {
//   var setDownColor = e(i)
//     setDownColor.classList.add('serverColor')
// } else if (showdata == "n") {
//   var setDownColor = e(i)
//     setDownColor.classList.add('nodeColor')
// }  else if (showdata == "undefined") {
//   var setDownColor = e(i)
//     setDownColor.classList.add('defualtColor')
// }

var deafulspeedType = setInterval(function() {
// readyDownDataArr()
// console.log("1!!!!!!!!!!!!!!!!!!!!")
}, 2000)

// 找到显示视频下载类型的格子
var findeVideoButton = function() {
  var findeClassButton = document.querySelectorAll('.insertButton')
  //  findeClassButton.classList.contains(')
  for (var i = 0; i < findeClassButton.length; i++) {
    var showclass = findeClassButton[i]
  // console.log(i, showclass)
  }
}

// supportWebRTC 的浏览器
var supportWebRTCBrower = function() {
  var html = `✕ WebRTC `
  var findbroser = document.querySelector('.input-group-addon')
  if (findbroser.classList.contains("source-header-setcolor")) {
    findbroser.classList.remove("source-header-setcolor")
    findbroser.innerText = ''
    findbroser.classList.add("changesource-header-setcolor")
    findbroser.innerText = html
  }
}

// 显示详细信息按钮
var showInfoForButton = function() {
  var findInforButton = document.querySelector('.dropdown')
  if (findInforButton.classList.contains("defalutStyleplay")) {
    findInforButton.classList.remove("defalutStyleplay")
  }
}

//点击播放按钮可以播放视频
var myvideo=document.getElementById('pearvideo');
myvideo.addEventListener('play',fn,false);//设置播放监听事件

function fn(){
  setPlayFuncitonforplaybutton() //调用播放器
  // setDownData()
  // setFirstaidSetarr()
  setManulPlayer()
  myvideo.removeEventListener('play',fn,false);//移除play监听事件
}